package cqu.edu.cn.interceptor;

import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;



/**
 * 主类的拦截器，拦截非主类的控制器对应的方法
 * @author 杨鑫隆and高鸿成
 *
 */
public class WebInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {  
        Object ssoToken = request.getSession().getAttribute("Token");
        if (ssoToken == null) {
            response.sendRedirect("/login");
        }
        return true;
    }

}